package com.ruoyi.business.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.domain.DistributionAwardRecord;
import com.ruoyi.business.mapper.DistributionAwardRecordMapper;
import com.ruoyi.business.service.IDistributionAwardRecordService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;


/**
 * 分销奖励请求记录Service业务层处理
 *
 * @author african-loan
 * @date 2022-07-21
 */
@Service
public class DistributionAwardRecordServiceImpl extends ServiceImpl<DistributionAwardRecordMapper, DistributionAwardRecord> implements IDistributionAwardRecordService {

    /**
     * 查询分销奖励请求记录
     *
     * @param id 分销奖励请求记录ID
     * @return 分销奖励请求记录
     */
    @Override
    public DistributionAwardRecord selectDistributionAwardRecordById(Long id) {
        return this.getById(id);
    }

    /**
     * 查询分销奖励请求记录列表
     *
     * @param distributionAwardRecord 分销奖励请求记录
     * @return 分销奖励请求记录
     */
    @Override
    public List<DistributionAwardRecord> selectDistributionAwardRecordList(DistributionAwardRecord distributionAwardRecord) {
        return this.list(new QueryWrapper<>(distributionAwardRecord).last("order by id desc"));
    }

    /**
     * 新增分销奖励请求记录
     *
     * @param distributionAwardRecord 分销奖励请求记录
     * @return 结果
     */
            @Override
    public int insertDistributionAwardRecord(DistributionAwardRecord distributionAwardRecord) {
                                                                                                                                                                                                    distributionAwardRecord.setCreateTime(DateUtils.getNowDate());
                                                                    return baseMapper.insert(distributionAwardRecord);
    }

    /**
     * 修改分销奖励请求记录
     *
     * @param distributionAwardRecord 分销奖励请求记录
     * @return 结果
     */
            @Override
    public int updateDistributionAwardRecord(DistributionAwardRecord distributionAwardRecord) {
                                                                                                                                                                                                                                            distributionAwardRecord.setUpdateTime(DateUtils.getNowDate());
                            return baseMapper.updateById(distributionAwardRecord);
    }

    /**
     * 批量删除分销奖励请求记录
     *
     * @param ids 需要删除的分销奖励请求记录ID
     * @return 结果
     */
            @Override
    public int deleteDistributionAwardRecordByIds(Long[] ids) {
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除分销奖励请求记录信息
     *
     * @param id 分销奖励请求记录ID
     * @return 结果
     */
    @Override
    public int deleteDistributionAwardRecordById(Long id) {
        return baseMapper.deleteById(id);
    }

}
